package com.ruoyi.web.controller.admin;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.system.domain.BdmRechargeSettings;
import com.ruoyi.system.service.IBdmRechargeSettingsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 充值设置Controller
 *
 * @author ruoyi
 * @date 2025-04-21
 */
@RestController
@RequestMapping("/system/settings")
public class BdmRechargeSettingsController extends BaseController
{
    @Autowired
    private IBdmRechargeSettingsService bdmRechargeSettingsService;

    /**
     * 查询充值设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:settings:list')")
    @GetMapping("/list")
    public TableDataInfo list(BdmRechargeSettings bdmRechargeSettings)
    {
        startPage();
        List<BdmRechargeSettings> list = bdmRechargeSettingsService.selectBdmRechargeSettingsList(bdmRechargeSettings);
        return getDataTable(list);
    }

    /**
     * 导出充值设置列表
     */
    @PreAuthorize("@ss.hasPermi('system:settings:export')")
    @Log(title = "充值设置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BdmRechargeSettings bdmRechargeSettings)
    {
        List<BdmRechargeSettings> list = bdmRechargeSettingsService.selectBdmRechargeSettingsList(bdmRechargeSettings);
        ExcelUtil<BdmRechargeSettings> util = new ExcelUtil<BdmRechargeSettings>(BdmRechargeSettings.class);
        util.exportExcel(response, list, "充值设置数据");
    }

    /**
     * 获取充值设置详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:settings:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(bdmRechargeSettingsService.selectBdmRechargeSettingsById(id));
    }

    /**
     * 新增充值设置
     */
    @PreAuthorize("@ss.hasPermi('system:settings:add')")
    @Log(title = "充值设置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BdmRechargeSettings bdmRechargeSettings)
    {
        return toAjax(bdmRechargeSettingsService.insertBdmRechargeSettings(bdmRechargeSettings));
    }

    /**
     * 修改充值设置
     */
    @PreAuthorize("@ss.hasPermi('system:settings:edit')")
    @Log(title = "充值设置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BdmRechargeSettings bdmRechargeSettings)
    {
        return toAjax(bdmRechargeSettingsService.updateBdmRechargeSettings(bdmRechargeSettings));
    }

    /**
     * 删除充值设置
     */
    @PreAuthorize("@ss.hasPermi('system:settings:remove')")
    @Log(title = "充值设置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bdmRechargeSettingsService.deleteBdmRechargeSettingsByIds(ids));
    }
}
